package com.chisheng.caa.pojo.dto;

import com.chisheng.caa.pojo.Bean;
import com.chisheng.caa.service.CollegeService;
import com.chisheng.caa.service.CourseAffiliationService;
import com.chisheng.caa.service.CourseNatureService;
import com.chisheng.caa.service.TeacherService;
import com.chisheng.caa.validator.Contains;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.lang.Nullable;

import javax.validation.constraints.*;
import java.io.Serializable;

import static com.chisheng.caa.config.CaaConfig.*;

@Data
@ApiModel("排课信息传输类")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CourseSchedulingDTO implements Serializable, Bean {

    private static final long serialVersionUID = 1L;

    @Nullable
    @ApiModelProperty("层次")
    @Contains(beanName = "validSchoolRunningLevelList", message = "{ArrangementCurriculum.schoolRunningLevel.message}")
    private String schoolRunningLevel;

    @NotBlank
    @ApiModelProperty(value = "课程代码", required = true)
    @Pattern(regexp = CourseDTO.COURSE_CODE_REGEX, message = "{ArrangementCurriculum.courseCode.message}")
    private String courseCode;

    @Nullable
    @ApiModelProperty("课程名称")
    @Size(min = 1, message = "{ArrangementCurriculum.courseName.message}")
    private String courseName;

    @Nullable
    @ApiModelProperty("课程性质")
    @Contains(beanClass = CourseNatureService.class, methodName = "getCourseNatureNameList", message = "{ArrangementCurriculum.courseNature.message}")
    private String courseNature;

    @Nullable
    @Contains(beanName = "validCourseTypeList", message = "{ArrangementCurriculum.courseTypeOrCourseAffiliation.message}")
    @ApiModelProperty("课程类别")
    private String courseType;

    @Nullable
    @Contains(beanClass = CourseAffiliationService.class, methodName = "getCourseAffiliationNameList", message = "{ArrangementCurriculum.courseTypeOrCourseAffiliation.message}")
    @ApiModelProperty("课程归属")
    private String courseAffiliation;

    @Nullable
    @ApiModelProperty("总体课程分类")
    @Contains(beanName = "validCourseCategoryList", message = "{ArrangementCurriculum.courseCategory.message}")
    private String courseCategory;

    @Nullable
    @ApiModelProperty("是否教师教育类课程")
    @Contains(beanName = "validBooleanValueCnList", message = "{ArrangementCurriculum.booleanValueCn.message}")
    private String isTeacherEducationCourse;

    @Nullable
    @ApiModelProperty("是否思想政治德育类课程")
    @Contains(beanName = "validBooleanValueCnList", message = "{ArrangementCurriculum.booleanValueCn.message}")
    private String isPoliticalCourse;

    @Nullable
    @ApiModelProperty("是否法制类课程")
    @Contains(beanName = "validBooleanValueCnList", message = "{ArrangementCurriculum.booleanValueCn.message}")
    private String isLawCourse;

    @Nullable
    @ApiModelProperty("是否民族类课程")
    @Contains(beanName = "validBooleanValueCnList", message = "{ArrangementCurriculum.booleanValueCn.message}")
    private String isNationalCourse;

    @Nullable
    @ApiModelProperty("是否外语类课程")
    @Contains(beanName = "validBooleanValueCnList", message = "{ArrangementCurriculum.booleanValueCn.message}")
    private String isForeignCourse;

    @Nullable
    @ApiModelProperty("是否美育类课程")
    @Contains(beanName = "validBooleanValueCnList", message = "{ArrangementCurriculum.booleanValueCn.message}")
    private String isAestheticCourse;

    @Nullable
    @ApiModelProperty("是否劳动教育类课程")
    @Contains(beanName = "validBooleanValueCnList", message = "{ArrangementCurriculum.booleanValueCn.message}")
    private String isLabourCourse;

    @Nullable
    @ApiModelProperty("理论学分")
    @DecimalMin(value = "0.0", message = "{ArrangementCurriculum.credit.message}")
    private Double theoreticalCredit;

    @Nullable
    @ApiModelProperty("实践学分")
    @DecimalMin(value = "0.0", message = "{ArrangementCurriculum.credit.message}")
    private Double practicalCredit;

    @Nullable
    @ApiModelProperty("理论学时")
    @Min(value = 0, message = "{ArrangementCurriculum.period.message}")
    private Integer theoreticalPeriod;

    @Nullable
    @ApiModelProperty("实践学时")
    @Min(value = 0, message = "{ArrangementCurriculum.period.message}")
    private Integer practicalPeriod;

    @Nullable
    @ApiModelProperty("起始教学周数")
    @Min(value = MIN_WEEKS, message = "{ArrangementCurriculum.numTeachingWeeks.message}")
    @Max(value = MAX_WEEKS, message = "{ArrangementCurriculum.numTeachingWeeks.message}")
    private Integer startingTeachingWeeks;

    @Nullable
    @ApiModelProperty("终止教学周数")
    @Min(value = MIN_WEEKS, message = "{ArrangementCurriculum.numTeachingWeeks.message}")
    @Max(value = MAX_WEEKS, message = "{ArrangementCurriculum.numTeachingWeeks.message}")
    private Integer terminalTeachingWeeks;

    @Nullable
    @ApiModelProperty("任课教师")
    @Contains(beanClass = TeacherService.class, methodName = "getTeacherNameList", message = "{ArrangementCurriculum.teacherName.message}")
    private String teacherName;

    @Nullable
    @ApiModelProperty("限选人数")
    @Min(value = 0, message = "{ArrangementCurriculum.roomCapacity.message}")
    private String roomCapacity;

    @Nullable
    @ApiModelProperty("建议年级")
    @Min(value = MIN_YEAR, message = "{ArrangementCurriculum.gradeSuggestion.message}")
    @Max(value = MAX_YEAR, message = "{ArrangementCurriculum.gradeSuggestion.message}")
    private Integer gradeSuggestion;

    @Nullable
    @ApiModelProperty("开课班级。可手动设定，若取值为 null，则转换为 Excel 表时会自动生成。")
    private String openingClass;

    @Nullable
    @ApiModelProperty("开课学院")
    @Contains(beanClass = CollegeService.class, methodName = "getCollegeNameList", message = "{ArrangementCurriculum.college.message}")
    private String openingCollege;

    @Nullable
    @ApiModelProperty("授课学院")
    @Contains(beanClass = CollegeService.class, methodName = "getCollegeNameList", message = "{ArrangementCurriculum.college.message}")
    private String teachingCollege;

    @Nullable
    @ApiModelProperty("授课教师所属学院")
    @Contains(beanClass = CollegeService.class, methodName = "getCollegeNameList", message = "{ArrangementCurriculum.college.message}")
    private String collegeOfTeacher;

    @Nullable
    @ApiModelProperty("实训室\\实验室节数（每周）")
    @Min(value = 0, message = "{ArrangementCurriculum.numLaboratories.message}")
    private Integer numLaboratories;

    @Nullable
    @ApiModelProperty("多媒体节数（每周）")
    @Min(value = 0, message = "{ArrangementCurriculum.numMedias.message}")
    private Integer numMedias;

    @Nullable
    @ApiModelProperty("机房节数（每周）")
    @Min(value = 0, message = "{ArrangementCurriculum.numMachineRooms.message}")
    private Integer numMachineRooms;

    @Nullable
    @ApiModelProperty("特殊要求")
    private String specialRequirements;

    @Nullable
    @ApiModelProperty("备注")
    private String attachment;

    @Override
    @JsonIgnore
    public String getKey() {
        return courseCode;
    }

}
